<!--
 * @Descripttion: 劳资专管员信息录入
 * @version:
 * @Author: zhangfan
 * @email: 2207044692@qq.com
 * @Date: 2020-07-19 13:46:23
 * @LastEditors: zhangfan
 * @LastEditTime: 2021-07-02 16:34:05
-->
<template>
  <el-dialog
    title="劳资专管员信息录入"
    :visible.sync="dialogVisible"
    @close="closeDialog('addBox')"
    :close-on-click-modal="false"
    :modal-append-to-body="false"
    width="550px"
  >
    <el-form :model="addForm" :rules="ruleAdd" ref="addBox">
      <p style="margin-bottom: 20px">项目未录入劳资专管员信息，请尽快录入。</p>
      <div style="text-align: center">
        <el-button type="primary" @click.native="improveStaff" class="save"
          >去录入</el-button
        >
      </div>
    </el-form>
  </el-dialog>
</template>

<script>
import { mapState } from 'vuex'
export default {
  data() {
    return {
      activeNames: [],
      typeOptions: [],
      dialogVisible: false,
      isShow: true,
      projectItem: '',
      projectList: '',
      showEmployeeList: '',
      waitPaySalary: 0,
      waitAuditAccout: 0,
      formLabelWidth: '170px',
      addForm: {
        name: '',
        tel: '',
      },
      ruleAdd: {
        name: [
          {
            required: true,
            message: '请输入劳资专管员姓名',
            trigger: 'blur',
          },
        ],
        tel: [
          {
            required: true,
            message: '请输入劳资专管员联系电话',
            trigger: 'blur',
          },
        ],
      },
    }
  },
  created() {
    //判断该项目是否添加了劳资专管员
    this.getIsUser()
  },
  computed: {
    ...mapState(['projectId', 'projectName']),
  },
  methods: {
    /**
     * @description:判断该项目是否添加了劳资专管员
     */
    getIsUser() {
      const vm = this
      vm.axios({
        method: 'post',
        url: 'api-e/cs/contract/expand/countbytype',
        data: {
          projectId: this.projectId,
          type: '60',
        },
      })
        .then((response) => {
          if (response.data.result == 0) {
            this.dialogVisible = true
          } else {
            this.dialogVisible = false
          }
        })
        .catch((error) => {
          //弹窗出来一次
          vm.$message.closeAll()
          vm.$message({
            showClose: true,
            duration: 3000,
            message: '获取数据失败',
            type: 'error',
          })
        })
    },
    //关闭弹窗
    closeDialog(ele) {
      this.$refs[ele].resetFields()
    },
    // 弹框的取消功能
    cancel(ele) {
      this.dialogVisible = false
    },
    /**
     * @description: 完善劳资专管员
     */
    improveStaff() {
      this.$router.push({
        name: 'employeeAddJz',
        path: '/home/employee/employeeAddJz',
        query: {
          path: 'projectEmployeeQY',
          projectId: this.projectId,
          projectName: this.projectName,
          userType: '60',
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/employee/projectEmployeeQY',
        newUrl: this.$router.currentRoute.fullPath,
      })
      this.dialogVisible = false
    },
  },
}
</script>

<style scoped lang="less">
.linkStyle {
  cursor: pointer;
  color: #057cf7;
}
/deep/ .el-dialog__header {
  padding: 20px 20px 10px !important;
}
</style>
